using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Atom.Data.ManagerObjects;
using Atom.Data.BusinessObjects;
using Atom.Data.Base;

namespace Atom.Data.UnitTests
{
	[TestFixture]
    public partial class HLeavehosleechdomDetailTests : UnitTestbase
    {
        [SetUp]
        public void SetUp()
        {
            manager = managerFactory.GetHLeavehosleechdomDetailManager();
            manager.Session.BeginTransaction();
        }

        [TearDown]
        public void TearDown()
        {
            manager.Session.RollbackTransaction();
            manager.Dispose();
        }
        
        protected Atom.Data.ManagerObjects.IHLeavehosleechdomDetailManager manager;
		
		protected Atom.Data.BusinessObjects.HLeavehosleechdomDetail CreateNewHLeavehosleechdomDetail()
		{
			Atom.Data.BusinessObjects.HLeavehosleechdomDetail entity = new Atom.Data.BusinessObjects.HLeavehosleechdomDetail();
			
			
			entity.Inhosid = "Test Tes";
			entity.Currentinhosmark = 11;
			entity.Detailaccountid = "Test";
			entity.Leechdomno = "Test Test T";
			entity.Leechdombatch = "Test";
			entity.Leechdomstate = 19;
			entity.Buyprice = 64;
			entity.Amount = 29;
			entity.Wholesaleprice = 61;
			entity.Money = 6;
			entity.Retailprice = 8;
			entity.Storeroomid = "Test Test ";
			entity.Operatedate = System.DateTime.Now;
			
			return entity;
		}
		protected Atom.Data.BusinessObjects.HLeavehosleechdomDetail GetFirstHLeavehosleechdomDetail()
        {
            IList<Atom.Data.BusinessObjects.HLeavehosleechdomDetail> entityList = manager.GetAll(1);
            if (entityList.Count == 0)
                Assert.Fail("All tables must have at least one row for unit tests to succeed.");
            return entityList[0];
        }
		
		[Test]
        public void Create()
        {
            try
            {
				Atom.Data.BusinessObjects.HLeavehosleechdomDetail entity = CreateNewHLeavehosleechdomDetail();
				
                object result = manager.Save(entity);

                Assert.IsNotNull(result);
            }
            catch(Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
        [Test]
        public void Read()
        {
            try
            {
                Atom.Data.BusinessObjects.HLeavehosleechdomDetail entityA = CreateNewHLeavehosleechdomDetail();
				manager.Save(entityA);

                Atom.Data.BusinessObjects.HLeavehosleechdomDetail entityB = manager.GetById(entityA.Id);

                Assert.AreEqual(entityA, entityB);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
		[Test]
		public void Update()
        {
            try
            {
                Atom.Data.BusinessObjects.HLeavehosleechdomDetail entityA = GetFirstHLeavehosleechdomDetail();
				
				entityA.Buyprice = 5;
				
				manager.Update(entityA);

                Atom.Data.BusinessObjects.HLeavehosleechdomDetail entityB = manager.GetById(entityA.Id);

                Assert.AreEqual(entityA.Inhosid, entityB.Inhosid);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
        [Test]
        public void Delete()
        {
            try
            {
                Atom.Data.BusinessObjects.HLeavehosleechdomDetail entity = GetFirstHLeavehosleechdomDetail();
				
                manager.Delete(entity);

                entity = manager.GetById(entity.Id);
                Assert.IsNull(entity);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        }
	}
}

